// --------------------------------------------------------------------------------------------------------------------
// <copyright file="GripperStatus.cs" company="Microsoft Corporation">
// The MIT License (MIT)
// 
// Copyright (c) 2014, Microsoft Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Microsoft.Robotics.Manipulation.PicknPlace
{
    using System;
    using System.Runtime.Serialization;
    using Microsoft.Robotics.Numerics;

    /// <summary>
    /// Generic description of Gripper status
    /// </summary>
    public class GripperStatus
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GripperStatus" /> class
        /// </summary>
        /// <param name="gripStateEnum">The desired state of the gripper</param>
        /// <param name="percentOpen">Degree to which gripper is open expressed as a percent</param>
        /// <param name="fingerState">State of the fingers</param>
        /// <param name="gripStyle">Grip style</param>
        public GripperStatus(GripperStateEnum gripStateEnum, double percentOpen, FingerStateEnum fingerState, GripStyle gripStyle)
        {
            this.GripStateEnum = gripStateEnum;
            this.PercentOpen = percentOpen;
            this.FingerState = fingerState;
            this.GripStyle = gripStyle;
        }

        /// <summary>
        /// Desired state of gripper 
        /// </summary>
        public enum GripperStateEnum
        {
            /// <summary>
            /// Open the gripper
            /// </summary>
            Open,

            /// <summary>
            /// Close the gripper
            /// </summary>
            Close,

            /// <summary>
            /// Do not care - state cannot be determined or does not matter
            /// </summary>
            Unknown
        }

        /// <summary>
        /// State of fingers
        /// </summary>
        public enum FingerStateEnum
        {
            /// <summary>
            /// Fingers are in motion
            /// </summary>
            InMotion,

            /// <summary>
            /// Fingers stationary
            /// </summary>
            Stopped,

            /// <summary>
            /// Do not care - use when finger state is unknown
            /// </summary>
            Unknown
        }

        /// <summary>
        /// Gets the grip style
        /// </summary>
        public GripStyle GripStyle { get; private set; }

        /// <summary>
        /// Gets a value indicating the desired state for the gripper
        /// This is usually related to PercentOpen but can be different when the gripper is in
        /// motion
        /// </summary>
        public GripperStateEnum GripStateEnum { get; private set; }

        /// <summary>
        /// Gets a value indicating finger status
        /// </summary>
        public FingerStateEnum FingerState { get; private set; }

        /// <summary>
        /// Gets the percent of gripper's open state. A value of 100 is fully open and 0 is fully closed
        /// </summary>
        public double PercentOpen { get; private set; }
    }
}
